#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
    int m = 0; int n = 0;
    int i = 0; 
    scanf("%d%d", &m,&n);
    int arr1[m];
    int arr2[n];
    for (i = 0; i < m; i++)
    {
        scanf("%d", &arr1[i]);
    }
    for (i = 0; i < n; i++)
    {
        scanf("%d", &arr2[i]);
    }
    int j = 0; int k = 0;
    while (j < m && k < n)
    {
        if (arr1[j] < arr2[k])
        {
            printf("%d ", arr1[j]);
            j++;
        }
        else
        {
            printf("%d ", arr2[k]);
            k++;
        }
    }
    while (j < m)
    {
        printf("%d ", arr1[j]);
        j++;
    }
    while (k < n)
    {
        printf("%d ", arr2[k]);
        k++;
    }
    return 0;
}